﻿@using TomNet.IMSC.Model.DbModels.Decoration
@{
    Layout = null;
    var entity = ViewData["entity"] as DecorationCompany;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">

    <title>Insert</title>
    <style>

    </style>
</head>
<body>
    <div class="wrapper wrapper-content animated fadeInRight">
        @*<div class="row"></div>*@
        <form class="form-horizontal m-t" id="mainForm">
            <input type="hidden" id="Id" name="Id" value="@entity.Id" />
            <input type="hidden" id="CreatedTime" name="CreatedTime" value="@entity.CreatedTime" />
            <input type="hidden" id="IsLocked" name="IsLocked" value="@entity.IsLocked" />
            <input type="hidden" id="IsDeleted" name="IsDeleted" value="@entity.IsDeleted" />
            <input type="hidden" id="StaffID" name="StaffID" value="@entity.MediumOfCommunicationStaffID" />
            <input type="hidden" id="AgentID" name="AgentID" value="@entity.AgentID" />
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">名称：</label>
                        <div class="col-xs-8">
                            <input id="Name" name="Name" type="text" value="@entity.Name" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">简介：</label>
                        <div class="col-xs-8">
                            <input id="DecorationCompanyInfo" name="DecorationCompanyInfo" type="text" value="@entity.DecorationCompanyInfo" class="form-control">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">佣金：</label>
                        <div class="col-xs-8">
                            <input id="Brokerage" name="Brokerage" type="text" value="@entity.Brokerage" class="form-control">                            
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">结算周期：</label>
                        <div class="col-xs-8">
                            <input id="CommissionAccount" name="CommissionAccount" type="text" value="@entity.CommissionAccount" class="form-control" placeholder="注：首付款后">
                        </div>
                    </div>
                </div>
            </div>

 
            <div class="row">
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">业务员(本公司)：</label>
                        <div class="col-xs-8">
                            <select class="form-control sel" id="MediumOfCommunicationStaffID" name="MediumOfCommunicationStaffID"></select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">奖励说明：</label>
                        <div class="col-xs-8">
                            <input id="AwardDescription" name="AwardDescription" type="text" value="@entity.AwardDescription" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">优惠信息：</label>
                        <div class="col-xs-8">
                            <input id="Preferential" name="Preferential" type="text" value="@entity.Preferential" class="form-control">                           
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">收费标准：</label>
                        <div class="col-xs-8">
                            <input id="FeeScale" name="FeeScale" type="text" value="@entity.FeeScale" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">佣金规则：</label>
                        <div class="col-xs-10">
                            <input id="BandSawBrokerage" name="BandSawBrokerage" type="text" value="@entity.BandSawBrokerage" class="form-control">                            
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">报备规则：</label>
                        <div class="col-xs-10">
                            <input id="FilingRules" name="FilingRules" type="text" value="@entity.FilingRules" class="form-control">
                        </div>
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">带看规则：</label>
                        <div class="col-xs-10">
                            <input id="BandSawRules" name="BandSawRules" type="text" value="@entity.BandSawRules" class="form-control">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">成交规则：</label>
                        <div class="col-xs-10">
                            <input id="TransactionRules" name="TransactionRules" type="text" value="@entity.TransactionRules" class="form-control">
                        </div>
                    </div>
                </div>
            </div>   
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">备注：</label>
                        <div class="col-xs-10">
                            <input id="Remark" name="Remark" type="text" value="@entity.Remark" class="form-control">
                        </div>
                    </div>
                </div>                
            </div>

            <div class="row">
                <div class="col-sm-6">

                </div>
                <div class="col-sm-6">
                    <div class="pull-right">
                        <button id="submit" class="btn btn-primary pull-center" type="submit">
                            <i class="fa fa-check"></i>&nbsp;提&nbsp;交
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>

    <!-- jQuery Validation plugin javascript-->
    <script type="text/javascript" src="~/Scripts/plugins/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/validate/messages_zh.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Extensions/ExtValidator.js"></script>

    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script>
        //加载基本数据
        $.ajax({
            url: "/DecorationRunnings/DictionaryLoad", type: "post", async: false, success: function (data) {
                if (data.type == 1) {
                    data = data.data;
                    //渠道人员
                    $("#MediumOfCommunicationStaffID").empty();
                    for (var i = 0; i < data.staff.length; i++) {
                        if (data.staff[i].id == $("#StaffID").val()) {                            
                            $("<option></option>").val(data.staff[i].id).text(data.staff[i].text).attr("selected", true).appendTo($("#MediumOfCommunicationStaffID"));
                        }
                        else {
                            $("<option></option>").val(data.staff[i].id).text(data.staff[i].text).appendTo($("#MediumOfCommunicationStaffID"));
                        }
                        
                    }
                }
            }
        });
        $(function () {
            // validate signup form on keyup and submit
            var icon = "<i class='fa fa-times-circle'></i> ";
            var validator = $("#mainForm").validate({
                rules: {
                    Name: {
                        required: true,
                        maxlength: 50
                    }, Brokerage: {
                        required: true
                    }, BandSawBrokerage: {
                        required: true
                    }, ShowIndex: {
                        required: true,
                        digits: true,
                        maxlength: 5
                    }, State: {
                        required: true,
                        digits: true,
                        maxlength: 5
                    }
                },
                messages: {
                    Name: {
                        required: icon + "请输入装修公司名称",
                        maxlength: icon + "门店名称过长"
                    }
                    , Brokerage: {
                        required: icon + "请输入佣金"
                    }, BandSawBrokerage: {
                        required: icon + "请输入佣金规则"
                    }
                    , ShowIndex: {
                        required: icon + "请输入显示顺序",
                        maxlength: icon + "位数过长"
                    }, State: {
                        required: icon + "请输入状态",
                        maxlength: icon + "位数过长"
                    }
                },
                submitHandler: function (form) {
                    //进行ajax传值
                    $.ajax({
                        url: "/Decoration/DecorationCompany/EditAsync",
                        type: "post",
                        dataType: "json",
                        data: $('#mainForm').serialize(),
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }
            });
        });
    </script>
</body>
</html>
